package com.cug.campus_sh_market_server.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.cug.campus_sh_market_server.entity.param.college.CollegeAddParam;
import com.cug.campus_sh_market_server.entity.param.college.CollegePutParam;
import com.cug.campus_sh_market_server.entity.param.college.CollegeQueryParam;
import com.cug.campus_sh_market_server.entity.po.College;
import com.cug.campus_sh_market_server.entity.vo.college.CollegeVO;
import com.cug.campus_sh_market_server.mapper.CollegeMapper;
import com.cug.campus_sh_market_server.service.CollegeService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 学院 服务实现类
 * </p>
 *
 * @author sxt
 * @since 2022-03-22
 */
@Service
public class CollegeServiceImpl
        extends CustomRestfullServiceImpl<College, CollegeQueryParam, CollegeAddParam, CollegePutParam, CollegeVO>
        implements CollegeService {
    @Override
    public CollegeVO saveWithBackData(CollegeAddParam collegeAddParam) {
        int count = this.count(new QueryWrapper<College>().lambda().eq(College::getCollege, collegeAddParam.getCollege()));
        if (count > 0) {
            return null;
        }
        return super.saveWithBackData(collegeAddParam);
    }
}
